<?php
include 'common/check.php';
include 'common/json.php';
include 'common/smarty.php';
include '../business/category_manager.php';
include '../business/market_manager.php';
include '../business/address_manager.php';
include '../business/folder_manager.php';
include_once '../entity/category_entity.php';
include_once '../entity/market_entity.php';
include_once '../entity/address_entity.php';
include_once '../entity/folder_entity.php';

$categoryMng    = new CategoryMng();
$marketMng      = new MarketMng();
$addressMng     = new AddressMng();
$json           = new Services_JSON();
$folderMng      = new FolderMng();

$categoryList   = $categoryMng->getAll(0, -2, "id", "ASC");
$categoryJson   = $json->encode($categoryList);
$marketList     = $marketMng->getAll(0, -2, "id", "ASC");
$addressList    = $addressMng->getAll(0 , -2, "id", "ASC");
$folderList     = $folderMng->getAll(0, -2, "id", "ASC");
$neededDate     = $awardDate = $deliveryDate = date("Y-m-d");
$addressID      = $addressList[0]['id'];
$name           = $addressList[0]['name'];
$address1       = $addressList[0]['address1'];
$address2       = $addressList[0]['address2'];
$address3       = $addressList[0]['address3'];
$city           = $addressList[0]['city'];
$country        = $addressList[0]['country'];
$province       = $addressList[0]['province'];
$zipCode        = $addressList[0]['zipCode'];

$tpl->assign("category_arr",    $categoryList);
$tpl->assign("category_json",   $categoryJson);
$tpl->assign("market_arr",      $marketList);
$tpl->assign("address_arr",     $addressList);
$tpl->assign("folder_arr",      $folderList);
$tpl->assign("neededDate",      $neededDate);
$tpl->assign("awardDate",       $awardDate);
$tpl->assign("deliveryDate",    $deliveryDate);
$tpl->assign("addressID",       $addressID);
$tpl->assign("name",            $name);
$tpl->assign("address1",        $address1);
$tpl->assign("address2",        $address2);
$tpl->assign("address3",        $address3);
$tpl->assign("city",            $city);
$tpl->assign("country",         $country);
$tpl->assign("province",        $province);
$tpl->assign("zipCode",         $zipCode);

/*if (isset($_SESSION['rfq_id'])) {
    $tpl->assign("cateogryID", $_SESSION['rfq_categoryID']);
    $tpl->assign("marketID", $_SESSION['rfq_marketID']);
    $tpl->assign("process", $_SESSION['rfq_process']);
    list($quantity1, $quantity2, $quantity3) = split("~", $SESSION['qty']);
    $tpl->assign("quantity1", $quantity1);
    $tpl->assign("quantity2", $quantity1);
    $tpl->assign("quantity3", $quantity1);
    $tpl->assign("measure", $_SESSION['rfq_measure']);
    $tpl->assign("annualUsage", $_SESSION['rfq_annualUsage']);
    $tpl->assign("neededDate", $_SESSION['rfq_neededDate']);
    $tpl->assign("awardDate", $_SESSION['rfq_awardDate']);
    $tpl->assign("deliveryDate", $_SESSION['rfq_deliveryDate']);
    $tpl->assign("paymentTerm", $_SESSION['rfq_paymentTerm']);
    $tpl->assign("quoteIn", $_SESSION['rfq_quoteIn']);
    $tpl->assign("targetPrice", $_SESSION['rfq_targetPrice']);
    $tpl->assign("folder", $_SESSION['rfq_folder']);
    $tpl->assign("shippingCost", $_SESSION['rfq_shippingCost']);
    $tpl->assign("addressID", $_SESSION['rfq_addressID']);
    $tpl->assign("instructions", $_SESSION['rfq_instructions']);
    $tpl->assign("requiredNDA", $_SESSION['rfq_requiredNDA']);
}*/

$tpl->display("rfq.html");

unset($categoryList);
unset($marketList);
unset($addressList);

?>
